﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace System
{
    public static class CommonExtensions
    {
        /// <summary>
        /// Convert string to int
        /// </summary>
        /// <param name="value">Original String</param>
        /// <param name="defalutvalue">Defalut Value</param>
        /// <returns>value of Convert</returns>
        /// Now only the basic types of conversion
        public static T ConvertTo<T>(this IConvertible value)
        {
            try
            {
                return (T)Convert.ChangeType(value, typeof(T));
            }
            catch (Exception)
            {
                return default(T);
            }
        }

        /// <summary>
        /// Check object is null rel
        /// </summary>
        /// <param name="obj">obj</param>
        /// <returns>if is null return true,ther return false</returns>
        public static bool IsNull(this object obj)
        {
            if (obj == null)
                return true;

            return false;
        }
    }
}
